package net.lzzy.practices.repositories;

import net.lzzy.practices.entities.Course;
import net.lzzy.practices.entities.User;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

public interface CourseRepository extends JpaRepository <Course, UUID>{
    List<Course> findAllByOrderByUpdateTimeDesc();

    List<Course> findAllByOrderByUpdateTimeDesc(Pageable pageable);
    List<Course> findCourseByOpenIsOrderByUpdateTimeDesc(boolean open);
    List<Course> findCourseByOpenIsOrderByUpdateTimeDesc(Pageable pageable, boolean open);

    Integer countAllBy();
    Integer countCourseByOpenIs(boolean open);
    List<Course>findCourseByTeacherIdEqualsOrderByCreateTime(UUID Id);
    List<Course> findCourseByStudentsContainsAndOpenOrderByUpdateTimeDesc(User student, boolean open);
}
